<?php
/**
 * Integration test with Example1.
 *
 * @author      Frank Kleine <mikey@xjconf.net>
 * @package     XJConf
 * @subpackage  test_integration
 */
require_once EXAMPLES_DIR . '/Color.php';
require_once EXAMPLES_DIR . '/Complex.php';
require_once EXAMPLES_DIR . '/UpperString.php';
/**
 * Integration test with Example1.
 *
 * @package     XJConf
 * @subpackage  test_integration
 */
class Example1TestCase extends UnitTestCase
{
    /**
     * test if example1 works
     */
    public function testExample1()
    {
        $tagParser = new DefinitionParser();
        $defs      = $tagParser->parse(EXAMPLES_DIR . '/xml/defines.xml');
        $this->assertEqual($defs->countTagDefinitions(), 9);
        
        $conf = new XmlParser();
        $conf->setTagDefinitions($defs);
        $conf->parse(EXAMPLES_DIR . '/xml/test.xml');
        
        $this->assertEqual($conf->getConfigValue('foo'), 'tomato');
        $this->assertEqual($conf->getConfigValue('zahl'), 124);
        $this->assertEqual($conf->getConfigValue('schst')->getString(), 'TOMATO');
        $this->assertEqual($conf->getConfigValue('complex')->render(), '<font color="red" size="3">This is a string.</font>');
        $this->assertEqual($conf->getConfigValue('complex2')->render(), '<font title="This text is written in dark-blue (A dark blue)" color="#01450" size="3"></font>');
        $this->assertEqual($conf->getConfigValue('array'), array('foo', 'bar'));
        $this->assertEqual($conf->getConfigValue('complex3')->render(), '<font color="" size="200"></font>');
    }
}
?>